define(['app'], function(app) {
	'use strict';

	// 实例化方法
	var factory = function(Http) {
		function get_data_getlist(result){
			if(false) {
				result = '{"success": true,"msg": "","result": {"store_count": "500","data": [' +
					'{"goods_id": 1,"name": "十字螺丝刀","introduce": "十字螺丝刀","price": 5.5,"mktprice": 8,' +
					'"preprice": 5.5,"store_id": "WuJin_1","store_name": "五金一店","image": "img/upload/pro-img01.jpg","storenumber": 100,' +
					'"salenumber": 20,"personlimit": 3,"qq": "1234567","phone": "18912345678","popularity":5000},' +
					'{"goods_id": 2,"name": "一字螺丝刀","introduce": "一字螺丝刀","price": 5.5,"mktprice": 8,' +
					'"preprice": 5.5,"store_id": "WuJin_1","store_name": "五金一店","image": "img/upload/pro-img01.jpg","storenumber": 80,' +
					'"salenumber": 10,"personlimit": 3,"qq": "1234567","phone": "18912345678","popularity":5000}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		// 返回信息
		return {
			// 获取数据
				getlist : function(nPage,cat_type, key, orderby, region, store_cat, act_id,callback,calldone) {
				Http.post({
					method:'goods.search.getlist', 
					cat_type:cat_type,
					key:key,
					orderby:orderby,
					picSize:'CS',
					region:region,
					store_cat:store_cat,
					act_id:act_id,
					pagelimit:20,
					nPage:nPage
				}, function(result) {
					//函数回调
					if(callback)
						callback(get_data_getlist(result).result);
				},function(err){

				},function(){
					if(calldone)
						calldone();
				});
			
			},
			
		};
	}

	factory.$inject = [ 'Http' ];
	return app.registerService("Secondhand", factory);
});